import web

count = 0

urls = (
    '/', 'index',
    '/init', 'init',
    '/increment', 'increment',
)

class index:
    def GET(self):
        return "Hello, world!"

class init:
    def GET(self):
        global count
        count = 0
	ret = '<?xml version="1.0"?><Value>' + str(count) + '</Value>'
	web.header('Content-Type', 'text/xml')
	web.header('Access-Control-Allow-Origin', '*')
	return ret
        
class increment:
    def GET(self):
        global count
        count = count + 1
	ret = '<?xml version="1.0"?><Value>' + str(count) + '</Value>'
	web.header('Content-Type', 'text/xml')
	web.header('Access-Control-Allow-Origin', '*')
	return ret

if __name__ == "__main__":
    app = web.application(urls, globals())
    app.run()

